package com.mili.camera2api;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
/**
 * Created by tutlane on 23-08-2017.
 */
public class CustomListAdapter extends BaseAdapter {
    private ArrayList<ListItem> listData;
    private LayoutInflater layoutInflater;
    public CustomListAdapter(Context aContext) {
	super();
        this.listData = new ArrayList<ListItem>();
        layoutInflater = LayoutInflater.from(aContext);
    }
     @Override
    public int getCount() {
        return listData.size();
    }
     @Override
    public Object getItem(int position) {
        return listData.get(position);
    }
     @Override
    public long getItemId(int position) {
        return position;
    }
    public  void add(String s){
	 ListItem it=new ListItem();
         it.setdata(s);
	 listData.add(it);
    }
   @Override
    public View getView(int position, View v, ViewGroup vg) {
        ViewHolder holder;
        if (v == null) {
            v = layoutInflater.inflate(R.layout.list_row, null);
            holder = new ViewHolder();
            //holder.uName = (TextView) v.findViewById(R.id.name);
            //holder.uDesignation = (TextView) v.findViewById(R.id.designation);
            //holder.uLocation = (TextView) v.findViewById(R.id.location);
            holder.uData = (TextView) v.findViewById(R.id.data);
            v.setTag(holder);
        } else {
            holder = (ViewHolder) v.getTag();
        }
        //holder.uName.setText(listData.get(position).getName());
        //holder.uDesignation.setText(listData.get(position).getDesignation());
        //holder.uLocation.setText(listData.get(position).getLocation());
        holder.uData.setText(listData.get(position).getdata());
        return v;
    }
    static class ViewHolder {
        //TextView uName;
        //TextView uDesignation;
        //TextView uLocation;
        TextView uData;
    }
}

